package com.ruoyi.web.controller.ddsystem;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DdOrderImg;
import com.ruoyi.system.service.IDdOrderImgService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单图片Controller
 * 
 * @author ruoyi
 * @date 2020-03-24
 */
@Controller
@RequestMapping("/system/order_img")
public class DdOrderImgController extends BaseController
{
    private String prefix = "system/order_img";

    @Autowired
    private IDdOrderImgService ddOrderImgService;

    @RequiresPermissions("system:order_img:view")
    @GetMapping()
    public String order_img()
    {
        return prefix + "/order_img";
    }

    /**
     * 查询订单图片列表
     */
    @RequiresPermissions("system:order_img:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DdOrderImg ddOrderImg)
    {
        startPage();
        List<DdOrderImg> list = ddOrderImgService.selectDdOrderImgList(ddOrderImg);
        return getDataTable(list);
    }

    /**
     * 导出订单图片列表
     */
    @RequiresPermissions("system:order_img:export")
    @Log(title = "订单图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DdOrderImg ddOrderImg)
    {
        List<DdOrderImg> list = ddOrderImgService.selectDdOrderImgList(ddOrderImg);
        ExcelUtil<DdOrderImg> util = new ExcelUtil<DdOrderImg>(DdOrderImg.class);
        return util.exportExcel(list, "order_img");
    }

    /**
     * 新增订单图片
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存订单图片
     */
    @RequiresPermissions("system:order_img:add")
    @Log(title = "订单图片", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DdOrderImg ddOrderImg)
    {
        return toAjax(ddOrderImgService.insertDdOrderImg(ddOrderImg));
    }

    /**
     * 修改订单图片
     */
    @GetMapping("/edit/{uuid}")
    public String edit(@PathVariable("uuid") String uuid, ModelMap mmap)
    {
        DdOrderImg ddOrderImg = ddOrderImgService.selectDdOrderImgById(uuid);
        mmap.put("ddOrderImg", ddOrderImg);
        return prefix + "/edit";
    }

    /**
     * 修改保存订单图片
     */
    @RequiresPermissions("system:order_img:edit")
    @Log(title = "订单图片", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DdOrderImg ddOrderImg)
    {
        return toAjax(ddOrderImgService.updateDdOrderImg(ddOrderImg));
    }

    /**
     * 删除订单图片
     */
    @RequiresPermissions("system:order_img:remove")
    @Log(title = "订单图片", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(ddOrderImgService.deleteDdOrderImgByIds(ids));
    }
}
